package cn.thoughtworks.school.repositories;


import cn.thoughtworks.school.entities.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;
import java.util.Optional;

public interface UserRepository extends JpaRepository<User, Long> {

  @Query("from  User where  (username=?1 or email=?1) and password=?2")
  Optional<User> findByUsernameOrEmailAndPassword(String username, String password);

  User findByUsername(String username);

  List<User> getUserByEmail(String email);

  List<User> getUserByUsername(String userName);

}
